package com.ruoyi.supermarket.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.supermarket.domain.Xqpurchase;
import com.ruoyi.supermarket.service.IXqpurchaseService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 采购采退详情表Controller
 * 
 * @author ruoyi
 * @date 2024-05-22
 */
@RestController
@RequestMapping("/supermarket/xqpurchase")
public class XqpurchaseController extends BaseController
{
    @Autowired
    private IXqpurchaseService xqpurchaseService;

    /**
     * 查询采购采退详情表列表
     */
    @PreAuthorize("@ss.hasPermi('supermarket:xqpurchase:list')")
    @GetMapping("/list")
    public AjaxResult list(Xqpurchase xqpurchase)
    {
        List<Xqpurchase> list = xqpurchaseService.selectXqpurchaseList(xqpurchase);
        return success(list);
    }

    /**
     * 导出采购采退详情表列表
     */
    @PreAuthorize("@ss.hasPermi('supermarket:xqpurchase:export')")
    @Log(title = "采购采退详情表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Xqpurchase xqpurchase)
    {
        List<Xqpurchase> list = xqpurchaseService.selectXqpurchaseList(xqpurchase);
        ExcelUtil<Xqpurchase> util = new ExcelUtil<Xqpurchase>(Xqpurchase.class);
        util.exportExcel(response, list, "采购采退详情表数据");
    }

    /**
     * 获取采购采退详情表详细信息
     */
    @PreAuthorize("@ss.hasPermi('supermarket:xqpurchase:query')")
    @GetMapping(value = "/{pId}")
    public AjaxResult getInfo(@PathVariable("pId") Long pId)
    {
        return success(xqpurchaseService.selectXqpurchaseByPId(pId));
    }

    /**
     * 新增采购采退详情表
     */
    @PreAuthorize("@ss.hasPermi('supermarket:xqpurchase:add')")
    @Log(title = "采购采退详情表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Xqpurchase xqpurchase)
    {
        return toAjax(xqpurchaseService.insertXqpurchase(xqpurchase));
    }

    /**
     * 修改采购采退详情表
     */
    @PreAuthorize("@ss.hasPermi('supermarket:xqpurchase:edit')")
    @Log(title = "采购采退详情表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Xqpurchase xqpurchase)
    {
        return toAjax(xqpurchaseService.updateXqpurchase(xqpurchase));
    }

    /**
     * 删除采购采退详情表
     */
    @PreAuthorize("@ss.hasPermi('supermarket:xqpurchase:remove')")
    @Log(title = "采购采退详情表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{pIds}")
    public AjaxResult remove(@PathVariable Long[] pIds)
    {
        return toAjax(xqpurchaseService.deleteXqpurchaseByPIds(pIds));
    }
}
